<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>#1143 test</title>

  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">
  <link rel="stylesheet" href="../../../demo/demo.css"/>
  <script src="../../../dist/gridstack-all.js"></script>
  <style type="text/css">
    .grid-stack-item-removing {
      opacity: 0.8;
      filter: blur(5px);
    }
    .outer .grid-stack-item-content {
      background-color: transparent;
    }
    .outer .nested .grid-stack-item-content {
      background-color: #18bc9c;
    }
  </style>
</head>
<body>
  <h3>show dragging into sub grid</h3>
  <div class="row">
    <div class="col-md-2 d-none d-md-block">
      <div class="newWidget grid-stack-item">
        <div class="card-body grid-stack-item-content">
          <span>Drag me in into the dashboard!</span>
        </div>
      </div>
    </div>
    <div class="col-sm-12 col-md-10">
      <div class="grid-stack outer" gs-animate="yes">
        <div class="grid-stack-item" gs-x="0" gs-y="0" gs-w="12" gs-h="3">
          <div class="grid-stack-item-content">
            This nested grid accepts new widget with class "newWidget"<br/>
            The parent grid also accepts new widget but with a different class 'otherWidgetType'<br/>&nbsp;
            <div class="grid-stack nested"></div>
          </div>
        </div>
      </div>
    </div>
  </div>

  <script type="text/javascript">
    let grid = GridStack.init({ acceptWidgets: '.otherWidgetType' }, '.grid-stack.outer');
    let gridNest = GridStack.init({
      acceptWidgets: '.newWidget',
      itemClass: 'sub',
    }, '.grid-stack.nested');
    gridNest.load([
      {x:0, y:0, w:3, content:'1'},
      {x:3, y:0, w:3, content:'2'},
      {x:6, y:0, w:3, content:'2'},
      {x:9, y:0, w:3, content:'3'},
      {x:0, y:1, w:3, content:'4'},
      {x:3, y:1, w:3, content:'5'},
    ]);

    GridStack.setupDragIn('.newWidget', { appendTo: 'body', helper: 'clone' });
    
    grid.on('added removed change', function(e, items) {
      let str = '';
      items.forEach(function(item) { str += ' (x,y)=' + item.x + ',' + item.y; });
      console.log(e.type + ' ' + items.length + ' items:' + str );
    });
  </script>
</body>
</html>
